import type { Router } from 'vue-router'
import { useDict } from '@/composables/useDict'
import { API_DICTS } from '@/constants/athlete'

/**
 * 设置字典守卫，在路由切换前预加载所需字典
 */
export function setupDictionary(router: Router) {
	router.beforeEach((to, _from, next) => {
		// 运动员相关路由
		if (to.path.includes('athlete')) {
			const { init: initAthleteDicts } = useDict(API_DICTS as unknown as string[])
			initAthleteDicts()
		}

		next()
	})
}
